#include <iostream>
#include <algorithm>
#include <cstring>  
using namespace std;
#define DEBUG
#define int long long
#define L(u) (u<<1)
#define R(u) (u<<1|1)

const int N=1e5+10, INF=0x3f3f3f3f;
int n, q;

struct Node
{
    int l, r;
    int val, lz1, lz2;
}tree[N<<2];

inline void push_up(Node& U, Node &L, Node &R)
{
    U.val=L.val+R.val;
}

inline void push_up(int u)
{
    push_up(tree[u], tree[L(u)], tree[R(u)]);
}

void update(Node &U, int add, int modi) //更新节点信息
{
    U.sum
}

inline void push_down(int u)
{

}

inline void build(int u, int l, int r)
{
    tree[u].l=l, tree[u].r=r;
    int mid=(l+r)>>1;
    build(L(u), l, mid);
    build(R(u), mid+1, r);
    push_up(u);
    tree[u].lz1=INF;
}

void change(int u, int l, int r, int x)
{
    auto &U=tree[u], &L=tree[L(u)], &R=tree[R(u)];
    if(l<=U.l&&U.r<=r) update(u, 0, x);
}

void add(int l, int r, int x)
{
    auto &U=tree[u], &L=tree[L(u)], &R=tree[R(u)];
    if(l<=U.l&&U.r<=r) update(u, x, -1);
}

int query(int l, int r)
{

}


signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        freopen("./out.txt", "w", stdout);
    #endif
    scanf("%d%d", &n, &q);
    while(q--)
    {
        int op, l, r, x;
        cin >> op >> l >> r;
        if(op==1)
        {
            cin >> x;
            change(l, r, x);
        }
        else if(op==2)
        {
            cin >> x;
            add(l, r, x);
        }
        else if(op==3)
        {
            cout << query(l, r) << endl;
        }
    }
    return 0;
}